<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回除法的浮点数余数</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.fmod" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">fmod</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">fmod</span> &mdash; <span class="dc-title">返回除法的浮点数余数</span></p>

   </div>
 <div class="refsect1 description" id="refsect1-function.fmod-description">
  <h3 class="title">说明</h3>
   <div class="methodsynopsis dc-description">
    <span class="methodname"><strong>fmod</strong></span>
     ( <span class="methodparam"><span class="type">float</span> <code class="parameter">$x</code></span>
    , <span class="methodparam"><span class="type">float</span> <code class="parameter">$y</code></span>
    ) : <span class="type">float</span></div>

    <p class="para rdfs-comment">
     返回被除数（<code class="parameter">x</code>）除以除数（<code class="parameter">y</code>）所得的浮点数余数。余数（<var class="varname"><var class="varname">r</var></var>）的定义是：x
     = i * y + r，其中 <var class="varname"><var class="varname">i</var></var> 是整数。如果 <code class="parameter">y</code>
     是非零值，则 <var class="varname"><var class="varname">r</var></var> 和
     <code class="parameter">x</code> 的符号相同并且其数量值小于
     <code class="parameter">y</code>。
    </p>
   </div>

   <div class="refsect1 parameters" id="refsect1-function.fmod-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">x</code></dt>

     <dd>

      <p class="para">
       被除数
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">y</code></dt>

     <dd>

      <p class="para">
       除数
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.fmod-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <code class="parameter">x</code>/<code class="parameter">y</code>的浮点数余数。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.fmod-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4128">
    <p><strong>Example #1 <span class="function"><strong>fmod()</strong></span> 的使用</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$x&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">5.7</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$y&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">1.3</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fmod</span><span style="color: #007700">(</span><span style="color: #0000BB">$x</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$y</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;$r&nbsp;equals&nbsp;0.5,&nbsp;because&nbsp;4&nbsp;*&nbsp;1.3&nbsp;+&nbsp;0.5&nbsp;=&nbsp;5.7<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

  </div></div></div></body></html>